import http from '@/tool/http'
import axios from 'axios'
import url from '@/tool/api'
const state = {
	logData:[],
	name:undefined,
}
const mutations = {
	setlog(state,arr){
		state.logData = []
		state.name = arr[0].name
		if(arr[0].name){
			arr.filter(item=>{
				let str = item.create_time+'++++++'+item.name+item.remark
				let obj = {
					log:str
				}
				state.logData.push(obj)
			})
		}else{
			state.logData.push({log:'日志清空'})
		}
		
	}
}
const actions = {
	getlog({commit},name){
		return http({
			url:url.seachlog,
			method:'post',
			data:{name:name}
		}).then(res=>{
			console.log(res)
			if(res.data.code==='200'){
				commit('setlog',res.data.data)
			}
			return res.data.code
		})
	},
	dellog({commit},name){
		if(!name){
			name = state.name
		}
		return http({
			url:url.dellog,
			method:'post',
			data:{
				name:name
			}
		}).then(res=>{
			console.log(res)
			if(res.data.code === '200'){
				commit('setlog',[{}])
			}
			return res.date.code
		})
	}
	
}
const getters = {
	
}

export default {
	state,mutations,actions,getters
}